line = alt.Chart(df_sumandwint).mark_line(interpolate='basis').encode(
x = alt.X('Year:Q', scale=alt.Scale(domain=[1895, 2012])),
y='count(Gender)',
color=alt.Color('Gender')
)
# line = alt.Chart(df_sumandwint).mark_line(interpolate='basis').encode(
# x = alt.X('Year:Q', scale=alt.Scale(domain=[1895, 2012]), title = 'Year', titleFont='Lato Regular', titleFontSize=12),
# y=alt.Y('count(Gender)', titleFont='Lato Regular', titleFontSize=12),
# color=alt.Color('Gender')
# )
nearest = alt.selection(type='single', nearest=True, on='mouseover',
fields=['Year'], empty='none')
rules = alt.Chart(df_sumandwint).mark_rule(color='gray').encode(
x='Year',
).transform_filter(
nearest
)
text = line.mark_text(align='left', dx=5, dy=-5).encode(
text=alt.condition(nearest, 'count(Gender)', alt.value(' '))
)
selectors = alt.Chart(df_sumandwint).mark_point().encode(
x='Year',
opacity=alt.value(0),
).add_selection(
nearest
)
points = line.mark_point().encode(
opacity=alt.condition(nearest, alt.value(1), alt.value(0))
)
alt.layer(
line, selectors, rules, text, points
).configure(
background='#f3f7f7'
).configure_axis(
labelFont='Lato Regular', labelAngle=0, labelColor='#5d646f', domain=False, labelFontSize=12,
titleFont='Lato Regular Italic', titleFontSize=14, grid=True, gridColor='#5d646f', gridDash=[0.5, 0.5, 0.5], gridOpacity=0.4,
tickColor='#5d646f', tickDash=[0.5, 0.5, 0.5], tickOpacity=0.4
).configure_view(
stroke='#f3f7f7'
).configure_legend(
strokeColor='gray',
fillColor='#f3f7f7',
padding=10,
cornerRadius=10
).properties(
width=700, height=330, padding=30,
title = alt.TitleParams(text = 'Gender Participation in the Olympic games', anchor='start',
font = 'Lato Bold', fontSize = 18, color = '#3E454F')
)